﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
using Windows.Storage;

namespace Mutzl.Samples.VideoApp.YouTube.ViewModel
{
    // Todo: 11. ViewModel für Settings adaptieren.
    public class SettingsViewModel : ViewModelBase
    {
        [PreferredConstructor]
        public SettingsViewModel()
        {
            SettingsContainer = ApplicationData.Current.LocalSettings;
        }

        public static string TweetsUpdateIntervallInMinutesProperty = "TweetsUpdateIntervallInMinutes";
        public static string ShowTweetsProperty = "ShowTweets";

        private readonly ApplicationDataContainer SettingsContainer;


        public int TweetsUpdateIntervallInMinutes
        {
            get { return (int?)SettingsContainer.Values[TweetsUpdateIntervallInMinutesProperty] ?? 3; }
            set
            {
                SettingsContainer.Values[TweetsUpdateIntervallInMinutesProperty] = value;
                RaisePropertyChanged(() => TweetsUpdateIntervallInMinutes);
            }
        }

        public bool ShowTweets
        {
            get { return (bool?) SettingsContainer.Values[ShowTweetsProperty] ?? true; }
            set 
            { 
                SettingsContainer.Values[ShowTweetsProperty] = value;
                RaisePropertyChanged(() =>ShowTweets);
            }
        }

    }
}
